package com.example.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.example.demo.dto.OrderInfDto;
import com.example.demo.dto.OrderMangeDto;
import com.example.demo.dto.UserMangeDto;
import com.example.demo.dto.VipMangeDto;

public interface ManageMapper {

	@Select("select oid,onum,discrible,account,oprice,otime FROM orders,order_state,users WHERE ostate=order_state.id AND orders.uid=users.uid")
	List<OrderMangeDto> getOrder();
	
	@Select("SELECT uid,account,vlevel,ucast FROM users,vip WHERE users.vid=vip.vid;")
	List<UserMangeDto> getUser();
	
	@Delete("DELETE FROM orders WHERE oid=#{id}")
	int delOrder(int id);
	
	@Delete("DELETE FROM users WHERE uid=#{id}")
	int delUser(int id);
	
	@Select("SELECT vid,vlevel,vdiscount FROM vip")
	List<VipMangeDto> getVip();
	
	@Delete("DELETE FROM vip WHERE vid=#{vid}")
	int delVip(int vid);

	@Update("UPDATE vip SET vlevel=#{vlevel} , vdiscount=#{vdiscount}  where vid=#{vid}")
	int changeVip(int vid, String vlevel, double vdiscount);
	
	@Insert("INSERT INTO vip(vlevel,vdiscount) VALUES (#{vlevel},#{vdiscount})")
	int inVip(String vlevel, double vdiscount);
	
	@Insert("INSERT INTO feedback(ftitle,fmessage) VALUES (#{title},#{text})")
	int feedbackInf(String title, String text);
	
	@Select("SELECT onum,discrible,account,mname,ytname,selectedSets,oprice,otime \r\n" + 
			"FROM orders,movie,movie_hall,users,order_state\r\n" + 
			"WHERE orders.yid=movie_hall.ytid AND orders.mid=movie.id AND orders.uid=users.uid AND orders.ostate=order_state.id AND oid=#{oid}")
	OrderInfDto orderInf(int oid);
	
	
}
